Add settex import: adopt an existing configuration, proven equivalent - #73
Merged
Conversation
The adoption path for the problem this project exists to solve. Nobody rewrites a
working production configuration by hand, and a migration that is merely probably
right is worse than none — a missed key surfaces at runtime, in the environment
where it was missed.
settex import takes the base appsettings.json, picks up the sibling
appsettings.{Environment}.json files as env blocks, and generates the .settex.
Before writing anything it compiles the generated text through the real pipeline
and compares every flattened key — the way .NET's configuration provider sees
them, colon-separated and case-insensitive — against the originals. One differing
key and nothing is written; the differences are listed instead. The effective
configuration per environment is compared, base merged with overlay, because that
is what runs — the overlay's exact shape is an implementation detail of the delta.
Generation handles what a real family contains: keys that are Settex keywords
(env, settings — a real config can legitimately have them) and keys that are not
identifiers are quoted; a literal ${ in a value is escaped to $${; backslashes,
quotes, newlines and tabs are escaped; arrays of objects become tagged items;
empty arrays and empty objects survive. A key containing "${" is refused loudly,
since the parser rejects interpolation in keys and an unquotable key would
otherwise produce a file that cannot compile.
Proven against production reality before being committed: the Bitwarden server's
real Api configuration — 148 flattened keys, 26 array objects, empty arrays, deep
nesting — imports with exact parity, verified both by the built-in check and
independently by a real ConfigurationBuilder loading the original pair and the
generated pair side by side.
Five tests. The kitchen-sink round-trip covers every shape that broke something
this campaign; two prove the verifier itself can fail — a verifier that cannot is
a slogan, not a check; one pins the loud refusal; and a CLI end-to-end test
imports a family with a keyword key and an object array, then builds the written
file.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
La voie d'adoption pour le problème qui a fait naître ce projet. Personne ne réécrit à la main une configuration de production qui marche — et une migration probablement juste est pire que pas de migration : une clé manquée se manifeste à l'exécution, dans l'environnement où elle a été manquée.
La commande
Les
appsettings.{Environment}.jsonvoisins deviennent des blocsenvautomatiquement. Avant d'écrire quoi que ce soit, la commande compile le texte généré à travers le vrai pipeline et compare chaque clé aplatie — comme le provider .NET les voit, séparées par:et insensibles à la casse — avec les originaux. Une seule clé qui diffère, et rien n'est écrit : les écarts sont listés.La comparaison porte sur la configuration effective par environnement (base fusionnée avec l'overlay), parce que c'est ce qui tourne — la forme exacte de l'overlay est un détail d'implémentation du delta.
Ce que la génération encaisse
env,settings— un vrai config peut légitimement les avoir) → citées"Microsoft.AspNetCore","Content-Type") → citées${littéral dans une valeur → échappé en$${item { }, tableaux et objets vides préservés"${"→ refus bruyant, le parser rejetant l'interpolation dans les clésProuvé sur la réalité avant d'être commité
La configuration de production du serveur Bitwarden (148 clés aplaties, 26 objets de tableau, tableaux vides, imbrication profonde) s'importe avec parité exacte — vérifiée par le contrôle intégré et indépendamment par un vrai
ConfigurationBuilderchargeant les deux paires côte à côte.Tests
Cinq tests, dont deux qui prouvent que le vérificateur sait échouer — un vérificateur qui ne peut pas échouer est un slogan, pas un contrôle. Le kitchen-sink couvre chaque forme qui a cassé quelque chose durant cette campagne.
415 → 420 tests.
🤖 Generated with Claude Code